﻿@inherits EditOperationDialogBase<PositionDto, int,UserCenterResource>


<Form Loading="_dialogLoading.Value"
      Model="_editModel"
      LabelCol="new ColLayoutParam { Span = 8 }"
      WrapperCol="new ColLayoutParam { Span = 16 }"
      OnFinish="OnFormFinish"
      Context="model">
    <ResourceAuthorize ResourceKey="@CommonResourceKeys.SystemTenantAdministratorKey">
        <FormItem Label="@Localizer[nameof(SharedLocalResource.Tenant)]">
            <Select DataSource="_tenants"
                    @bind-Value="model.TenantId"
                    ValueName="@nameof(SystemTenantDto.Id)"
                    LabelName="@nameof(SystemTenantDto.Name)"
                    TItem="SystemTenantDto"
                    TItemValue="Guid?"
                    AllowClear>
            </Select>
        </FormItem>
    </ResourceAuthorize>
    <FormItem>
        <Input @bind-Value="@model.Name" />
    </FormItem>
    <FormItem>
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Target"></TextArea>
    </FormItem>
    <FormItem>
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Duty"></TextArea>
    </FormItem>
    <FormItem>
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Right"></TextArea>
    </FormItem>
    <FormItem>
        <Select DataSource="DictHelper.GetCodesFromCache<PositionDto>(() => model.Grade)"
                @bind-Value="model.Grade"
                ValueName="@nameof(CodeDto.CodeValue)"
                LabelName="@nameof(CodeDto.CodeName)"
                TItem="CodeDto"
                TItemValue="string"
                AllowClear>
        </Select>
    </FormItem>
    <FormItem>
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Qualifications"></TextArea>
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Salary" />
    </FormItem>
    <FormItem>
        <Switch @bind-Value="@model.IsLocked"></Switch>
    </FormItem>

    @if (this.Options.Type.Equals(OperationDialogInputType.Edit) || this.Options.Type.Equals(OperationDialogInputType.Select))
    {
        <FormItem Label="@Localizer[nameof(SharedLocalResource.CreatedTime)]">
            <span>@model.CreatedTime.ToString(ClientConstant.DateTimeFormat)</span>
        </FormItem>
        <FormItem Label="@Localizer[nameof(SharedLocalResource.UpdatedTime)]">
            <span>@model.UpdatedTime?.ToString(ClientConstant.DateTimeFormat)</span>
        </FormItem>
    }
    <FormItem WrapperColOffset="8" WrapperColSpan="16">
        <Space>
            @if (!OperationDialogInputType.Select.Equals(this.Options.Type))
            {
                <SpaceItem>
                    <Button Type="@ButtonType.Primary" HtmlType="submit">
                        @Localizer[nameof(SharedLocalResource.Save)]
                    </Button>
                </SpaceItem>
            }
            <SpaceItem>
                <Button OnClick="_=>OnFormCancel()">
                    @Localizer[nameof(SharedLocalResource.Cancel)]
                </Button>
            </SpaceItem>
        </Space>
    </FormItem>
</Form>